package com.ifengxue.plugin.gui.property;

import com.ifengxue.plugin.Holder;
import com.ifengxue.plugin.entity.ReactValueType;
import com.ifengxue.plugin.gui.annotation.EditorProvider;
import com.ifengxue.plugin.util.TypeUtil;
import com.intellij.openapi.editor.event.DocumentAdapter;
import com.intellij.openapi.editor.event.DocumentEvent;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.util.ui.ComboBoxCellEditor;
import com.intellij.util.ui.table.ComboBoxTableCellEditor;

import javax.swing.*;
import javax.swing.table.TableCellEditor;
import java.beans.PropertyDescriptor;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class ReactValueTypeEditorProvider implements EditorProvider {

  @Override
  public TableCellEditor createEditor(PropertyDescriptor pd) {
    ComboBoxCellEditor editor = new ComboBoxCellEditor() {
      protected List<String> getComboBoxItems() {
        return Arrays.stream(ReactValueType.values()).map(ReactValueType::toString).collect(Collectors.toList());
      }
    };
    return editor;
  }
}
